package written_test;

import java.util.*;
/**
 * @author zhx
 * @since 2020-08-15
 * <p>
 * 1 AC?
 * 2 AC
 * 3 82
 *
 */

public class MeiTuan {

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Pair[] pairs = new Pair[n];
        for (int i = 0; i < m; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
        }
        boolean modify = true;
        while (modify) {
            modify = false;
            for (int i = 0; i < pairs.length; i++) {
                for (int j = i + 1; j < pairs.length; j++) {
                    if (pairs[j] != null && pairs[i] != null) {
                        if (pairs[i].contain(pairs[j])) {
                            modify = true;
                            pairs[i].merge(pairs[j]);
                            pairs[j] = null;
                        }
                    }
                }
            }
        }
        List<Pair> result = new ArrayList<>();
        for (Pair pair : pairs) {
            if (pair != null){
                result.add(pair);
            }
        }
        System.out.println(result.size());
        result.forEach((pair)->{
            pair.set.stream().sorted().forEach((integer)->{
                System.out.print(integer+" ");
            });
        });


    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        Map<Integer, Integer> index_value_a = new HashMap<>();
        Map<Integer, Integer> index_value_b = new HashMap<>();
        List<Integer> used = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            index_value_a.put(i, in.nextInt());
            index_value_b.put(i, in.nextInt());
        }
        int count_a = 0;
        int count_b = 0;
        int sum = 0;
        Integer[] sorted_a_values = (Integer[]) index_value_a.values().stream().sorted().toArray();
        Integer[] sorted_b_values = (Integer[]) index_value_b.values().stream().sorted().toArray();
        while (count_a < a) {
            sum += sorted_a_values[count_a];
        }

    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Stack<String> tickets = new Stack<>();
        int count = 0;
        for (int i = 0; i < 2 * n; i++) {
            String tmp = in.next();
            tickets.add(tmp);
        }
        String start = tickets.pop();
        while (!tickets.empty()) {
            if (tickets.pop().equals(start)) {
                count++;
                if (!tickets.empty()) {
                    start = tickets.pop();
                }
            }
        }
        System.out.println(count);
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int end = n / 4;
        int count = 0;
        List<Integer[]> list = new ArrayList<>();
        for (int i = 1; i <= end; i++) {
            int tmp = i * 4;
            if (isReverse(String.valueOf(i), String.valueOf(tmp))) {
                count++;
                list.add(new Integer[]{i, tmp});
            }
        }
        System.out.println(count);
        list.forEach((integers) -> {
            System.out.println(integers[0] + " " + integers[1]);
        });
    }

    private static boolean isReverse(String a, String b) { //
        char[] a_arr = a.toCharArray();
        char[] b_arr = b.toCharArray();
        for (int i = 0; i < a_arr.length; i++) {
            if (a_arr[i] != b_arr[a_arr.length - 1 - i]) {
                return false;
            }
        }
        return true;
    }

    static class Pair {
        Set<Integer> set = new HashSet<>();

        public Pair(int a, int b) {
            this.set.add(a);
            this.set.add(b);
        }

        public boolean contain(int c) {
            return set.contains(c);
        }

        public boolean contain(Pair pair) {
            for (Integer integer : pair.set) {
                if (contain(integer)) {
                    return true;
                }
            }
            return false;
        }

        public void merge(Pair pair) {
            this.set.addAll(pair.set);
        }
    }
}
